<%@ Register TagPrefix="cc2" Namespace="PHSRAG.WebControls" Assembly="PHSRAG.WebControls" %>
<%@ Register TagPrefix="cc1" Namespace="PHSRAG.Insight21.InsightWebControls" Assembly="PHSRAG.Insight21.InsightWebControls" %>

<%@ Page Language="c#" Inherits="PHSRAG.Insight21.FormsManagement.Version" CodeFile="Version.aspx.cs" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Version</title>
    <link href="../Insight21.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript">
		function RestrictActiveVersionSelection(versionActive)
		{
		
			var rowPreviouslySelected = document.getElementById('activeVersionTracker');
			
			if (rowPreviouslySelected.value != '' && rowPreviouslySelected.value != versionActive)
			{
				var versionPreviouslyActive = document.getElementById(rowPreviouslySelected.value);
				versionPreviouslyActive.setAttribute('checked', false); // uncheck the previously selected radio
			}
			rowPreviouslySelected.value = versionActive; //save the current radio in the hidden field
		}
    </script>

</head>
<body>
    <form method="post" id="VersionForm" runat="server">
        <table class="Container" cellpadding="0">
            <tr>
                <td>
                    <table class="Header" width="100%">
                        <tr>
                            <td>
                                <cc1:Header ID="header" runat="server"></cc1:Header>
                            </td>
                        </tr>
                        <tr style="display: none">
                            <td>
                                <cc1:AdminSubNavigation ID="adminSubNavigation" runat="server" Visible="false"></cc1:AdminSubNavigation>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <cc1:AdminHumansSubNavigation ID="adminHumansSubNavigation" runat="server"></cc1:AdminHumansSubNavigation>
                                <cc1:CoISubNavigation ID="coiSubNavigation" runat="server"></cc1:CoISubNavigation>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;</td>
                        </tr>
                    </table>
                    <table width="100%" class="Placebar">
                        <tr align="left">
                            <td>
                                <cc2:BreadCrumb ID="breadCrumb" runat="server"></cc2:BreadCrumb>
                            </td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>
                                <cc2:Annunciator ID="annunciator" runat="server"></cc2:Annunciator>
                            </td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>
                                <cc2:PostbackGuard ID="postbackGuard" runat="server"></cc2:PostbackGuard>
                            </td>
                        </tr>
                    </table>
                    <asp:Panel ID="versionsPanel" runat="server" Visible="True">
                        <table width="100%">
                            <tr>
                                <td>
                                    <cc2:ExpandingPanel ID="helpContainer" runat="server" ExpansionToggler="expansionToggler">
                                        <StaticTemplate>
                                            <table class="Search">
                                                <tr>
                                                    <td>
                                                        <table id="expandedHelp" runat="server">
                                                            <tr>
                                                                <td>
                                                                    <cc2:ExpansionToggler ID="expansionToggler" runat="Server" CollapsedLinkCaption="Show Instructions"
                                                                        ExpandedLinkCaption="Hide Instructions" CollapsedImage="~/Images/Arrow_RT.gif"
                                                                        ExpandedImage="~/Images/Arrow_DN.gif"></cc2:ExpansionToggler>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </StaticTemplate>
                                        <DynamicTemplate>
                                            <table class="SearchDynamic">
                                                <tr>
                                                    <td>
                                                        &nbsp;</td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <ol>
                                                            <li>An initial version of your questionnaire has been created for you. To add questions
                                                                to the questionnaire, please click on the version number link.&nbsp;
                                                                <li>Modify the Questionnaire Name, Description, Type, Category and Category Sequence
                                                                    No, if necessary.
                                                                    <br>
                                                                    Note: The Questionnaire Name, Type and Category can only be modified, if none of
                                                                    the Questionnaire's versions are active.
                                                                    <li>Click 'Save' to save changes.
                                                                        <li>To add/modify questions within a version, click on the version number.
                                                                            <li>Click 'Create Version' to create a new version of the questionnaire.</li>
                                                        </ol>
                                                    </td>
                                                </tr>
                                            </table>
                                        </DynamicTemplate>
                                    </cc2:ExpandingPanel>
                                </td>
                            </tr>
                        </table>
                        <table>
                            <tr>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    <input id="activeVersionTracker" type="hidden" runat="server" /></td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Questionnaire Name:
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    <asp:TextBox ID="questionnaireName" runat="server" MaxLength="50" CssClass="FlatTextBox"
                                        Columns="50"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="nameValidator" runat="server" ErrorMessage="Name cannot be left empty"
                                        ControlToValidate="questionnaireName" Display="Dynamic"></asp:RequiredFieldValidator></td>
                            </tr>
                            <tr>
                                <td>
                                    <img alt="Clear" height="2" src="../Images/clear.gif" /></td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Questionnaire Description:
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    <asp:TextBox ID="questionnaireDescription" runat="server" Visible="True" MaxLength="250"
                                        CssClass="FlatTextBox" Columns="50" Rows="5" TextMode="MultiLine"></asp:TextBox></td>
                            </tr>
                            <tr>
                                <td>
                                    <img alt="Clear" height="2" src="../Images/clear.gif" /></td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Questionnaire Type:
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    <asp:DropDownList ID="questionnaireType" runat="server" CssClass="FlatDropDown" AutoPostBack="True"
                                        OnSelectedIndexChanged="OnQuestionnaireTypeSelectedIndexChanged">
                                    </asp:DropDownList></td>
                            </tr>
                            <tr>
                                <td>
                                    <img alt="Clear" height="2" src="../Images/clear.gif" /></td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Questionnaire Category:
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    <asp:DropDownList ID="questionnaireCategory" runat="server" CssClass="FlatDropDown">
                                    </asp:DropDownList></td>
                            </tr>
                            <tr>
                                <td>
                                    <img alt="Clear" height="2" src="../Images/clear.gif" /></td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Category Sequence No:
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    <asp:TextBox ID="questionnaireCategorySequenceNo" runat="server" MaxLength="4" CssClass="FlatTextBox"
                                        Columns="4"></asp:TextBox>
                                    <asp:RegularExpressionValidator ID="sequenceValidator" runat="server" ErrorMessage="Category Sequence No should be a number"
                                        ControlToValidate="questionnaireCategorySequenceNo" ValidationExpression="\d+"></asp:RegularExpressionValidator></td>
                            </tr>
                            <tr>
                                <td>
                                    <img alt="Clear" height="2" src="../Images/clear.gif" /></td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Allow Multiple:</td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    <asp:CheckBox ID="questionnaireAllowMultiple" runat="server" Text=""></asp:CheckBox></td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    &nbsp;</td>
                            </tr>
                        </table>
                        <table width="70%">
                            <tr>
                                <td align="left" colspan="3">
                                    <asp:Button ID="createVersion" runat="server" CssClass="Button" Text="Create Version"
                                        CommandName="CreateVersion" OnClick="OnCreateVersionClick"></asp:Button></td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    <cc2:Pager ID="topPager" runat="server"></cc2:Pager>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    <asp:DataGrid ID="questionnaireVersions" runat="server" CssClass="DataGrid" Width="100%"
                                        AutoGenerateColumns="False" AllowCustomPaging="True" AllowPaging="True" AllowSorting="True">
                                        <FooterStyle CssClass="DataGridHeader"></FooterStyle>
                                        <AlternatingItemStyle CssClass="DataGridAlternatingItem"></AlternatingItemStyle>
                                        <ItemStyle CssClass="DataGridItem"></ItemStyle>
                                        <HeaderStyle CssClass="DataGridHeader"></HeaderStyle>
                                        <Columns>
                                            <asp:TemplateColumn Visible="False" HeaderText="ID">
                                                <ItemTemplate>
                                                    <asp:Label ID="questionnaireVersionID" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.ID") %>'>
                                                    </asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateColumn>
                                            <asp:ButtonColumn DataTextField="Version" HeaderText="Version">
                                                <ItemStyle HorizontalAlign="Center" Width="7%"></ItemStyle>
                                            </asp:ButtonColumn>
                                            <asp:TemplateColumn HeaderText="Active">
                                                <ItemStyle HorizontalAlign="Center" Width="7%"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:RadioButton ID="versionActive" runat="server" GroupName="SelectVersion" Checked='<%#DataBinder.Eval(Container, "DataItem.IsActive") %>'>
                                                    </asp:RadioButton>
                                                </ItemTemplate>
                                            </asp:TemplateColumn>
                                            <asp:TemplateColumn HeaderText="Version Description">
                                                <ItemTemplate>
                                                    <asp:TextBox ID="versionDescription" runat="server" CssClass="FlatTextBox" Width="100%"
                                                        Rows="4" TextMode="MultiLine" Text='<%#DataBinder.Eval(Container, "DataItem.Description") %>'>
                                                    </asp:TextBox>
                                                </ItemTemplate>
                                            </asp:TemplateColumn>
                                        </Columns>
                                        <PagerStyle Visible="False"></PagerStyle>
                                    </asp:DataGrid></td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    <cc2:Pager ID="bottomPager" runat="server"></cc2:Pager>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    <img alt="Clear" height="1%" src="../Images/clear.gif" />
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Button ID="back" runat="server" CssClass="FixedWidthButton" Text="Back" CommandName="Back"
                                        CausesValidation="False" OnClick="OnBackClick"></asp:Button></td>
                                <td>
                                    &nbsp;</td>
                                <td align="right">
                                    <asp:Button ID="updateQuestionnaire" runat="server" CssClass="FixedWidthButton" Text="Save"
                                        CommandName="UpdateQuestionnaire" OnClick="OnUpdateQuestionnaireClick"></asp:Button></td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:Panel ID="createVersionPanel" runat="server" Visible="False">
                        <table>
                            <tr>
                                <td align="right">
                                    Description:
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    <asp:TextBox ID="newVersionDescription" runat="server" MaxLength="250" CssClass="FlatTextBox"
                                        Columns="50" Rows="5" TextMode="MultiLine"></asp:TextBox></td>
                            </tr>
                            <tr>
                                <td colspan="3">
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;</td>
                                <td>
                                </td>
                                <td>
                                    <table width="100%">
                                        <tr>
                                            <td align="center">
                                                <asp:Button ID="cancelVersion" runat="server" CssClass="FixedWidthButton" Text="Cancel"
                                                    CommandName="CancelVersion" OnClick="OnCancelVersionClick"></asp:Button></td>
                                            <td align="center">
                                                <asp:Button ID="saveVersion" runat="server" CssClass="FixedWidthButton" Text="Save"
                                                    CommandName="SaveVersion" OnClick="OnSaveVersionClick"></asp:Button></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <cc2:SetFocus ID="setFocus" runat="server" FocusControl="newVersionDescription"></cc2:SetFocus>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
